
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>编程风格 · JavaScript学习</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Veng">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../js扩展/js扩展.html" />
    
    
    <link rel="prev" href="异常处理.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="基础.html">
            
                <a href="基础.html">
            
                    
                    基础
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="变量.html">
            
                <a href="变量.html">
            
                    
                    数据类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="let和const命令.html">
            
                <a href="let和const命令.html">
            
                    
                    let和const命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="数值.html">
            
                <a href="数值.html">
            
                    
                    数值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="字符串.html">
            
                <a href="字符串.html">
            
                    
                    字符串
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.5" data-path="对象.html">
            
                <a href="对象.html">
            
                    
                    对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.6" data-path="数组.html">
            
                <a href="数组.html">
            
                    
                    数组
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.7" data-path="Symbol.html">
            
                <a href="Symbol.html">
            
                    
                    Symbol
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8" data-path="函数.html">
            
                <a href="函数.html">
            
                    
                    函数
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.8.1" data-path="函数的扩展.html">
            
                <a href="函数的扩展.html">
            
                    
                    函数的扩展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.2" data-path="变量的解构赋值.html">
            
                <a href="变量的解构赋值.html">
            
                    
                    变量作用域与解构赋值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.3" data-path="函数3.html">
            
                <a href="函数3.html">
            
                    
                    方法函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.4" data-path="高阶函数.html">
            
                <a href="高阶函数.html">
            
                    
                    高阶函数
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.8.4.1" data-path="map-reduce.html">
            
                <a href="map-reduce.html">
            
                    
                    map/reduce
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.4.2" data-path="filter.html">
            
                <a href="filter.html">
            
                    
                    filter
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.4.3" data-path="sort.html">
            
                <a href="sort.html">
            
                    
                    sort
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.4.4" data-path="array其他方法.html">
            
                <a href="array其他方法.html">
            
                    
                    array其他方法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.8.5" data-path="闭包.html">
            
                <a href="闭包.html">
            
                    
                    闭包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.6" data-path="箭头函数.html">
            
                <a href="箭头函数.html">
            
                    
                    箭头函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.7" data-path="../浏览器/Promise.html">
            
                <a href="../浏览器/Promise.html">
            
                    
                    Promise
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.8" data-path="generator.html">
            
                <a href="generator.html">
            
                    
                    generator
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.8.9" data-path="async.html">
            
                <a href="async.html">
            
                    
                    async
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.9" data-path="标准对象.html">
            
                <a href="标准对象.html">
            
                    
                    标准对象
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.9.1" data-path="SetMap.html">
            
                <a href="SetMap.html">
            
                    
                    Set,Map
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9.2" data-path="Date.html">
            
                <a href="Date.html">
            
                    
                    Date
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9.3" data-path="Math.html">
            
                <a href="Math.html">
            
                    
                    Math
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9.4" data-path="Proxy.html">
            
                <a href="Proxy.html">
            
                    
                    Proxy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9.5" data-path="RepExp.html">
            
                <a href="RepExp.html">
            
                    
                    正则表达式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9.6" data-path="正则表达式.html">
            
                <a href="正则表达式.html">
            
                    
                    正则表达式别篇
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.9.7" data-path="json.html">
            
                <a href="json.html">
            
                    
                    JSON
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.10" data-path="面向对象编程.html">
            
                <a href="面向对象编程.html">
            
                    
                    面向对象编程
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.10.1" data-path="对象的扩展.html">
            
                <a href="对象的扩展.html">
            
                    
                    对象的扩展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.10.2" data-path="创建对象.html">
            
                <a href="创建对象.html">
            
                    
                    创建对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.10.3" data-path="原型继承.html">
            
                <a href="原型继承.html">
            
                    
                    原型继承
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.10.4" data-path="class继承.html">
            
                <a href="class继承.html">
            
                    
                    class继承
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.10.5" data-path="模块化Module.html">
            
                <a href="模块化Module.html">
            
                    
                    模块化Module
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.2.11" data-path="异常处理.html">
            
                <a href="异常处理.html">
            
                    
                    异常处理
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.2.12" data-path="编程风格.html">
            
                <a href="编程风格.html">
            
                    
                    编程风格
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../js扩展/js扩展.html">
            
                <a href="../js扩展/js扩展.html">
            
                    
                    js 扩展
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../js扩展/字符串.html">
            
                <a href="../js扩展/字符串.html">
            
                    
                    字符串
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../浏览器/浏览器.html">
            
                <a href="../浏览器/浏览器.html">
            
                    
                    浏览器
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../浏览器/浏览器对象.html">
            
                <a href="../浏览器/浏览器对象.html">
            
                    
                    浏览器对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../浏览器/操作DOM.html">
            
                <a href="../浏览器/操作DOM.html">
            
                    
                    操作DOM
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.2.1" data-path="../浏览器/更新DOM.html">
            
                <a href="../浏览器/更新DOM.html">
            
                    
                    更新DOM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.2" data-path="../浏览器/插入DOM.html">
            
                <a href="../浏览器/插入DOM.html">
            
                    
                    插入DOM
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.3" data-path="../浏览器/删除DOM.html">
            
                <a href="../浏览器/删除DOM.html">
            
                    
                    删除DOM
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../浏览器/DOM事件.html">
            
                <a href="../浏览器/DOM事件.html">
            
                    
                    DOM事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../浏览器/操作表单.html">
            
                <a href="../浏览器/操作表单.html">
            
                    
                    操作表单
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../浏览器/操作文件.html">
            
                <a href="../浏览器/操作文件.html">
            
                    
                    操作文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../浏览器/AJAX.html">
            
                <a href="../浏览器/AJAX.html">
            
                    
                    AJAX
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../浏览器/Canvas.html">
            
                <a href="../浏览器/Canvas.html">
            
                    
                    Canvas
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../Jquery/jquery.html">
            
                <a href="../Jquery/jquery.html">
            
                    
                    Jquery
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../Jquery/选择器.html">
            
                <a href="../Jquery/选择器.html">
            
                    
                    选择器
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1.1" data-path="../Jquery/层级选择器.html">
            
                <a href="../Jquery/层级选择器.html">
            
                    
                    层级选择器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.1.2" data-path="../Jquery/查找和过滤.html">
            
                <a href="../Jquery/查找和过滤.html">
            
                    
                    查找和过滤
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../Jquery/操作DOM.html">
            
                <a href="../Jquery/操作DOM.html">
            
                    
                    操作DOM
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.2.1" data-path="../Jquery/修改DOM结构.html">
            
                <a href="../Jquery/修改DOM结构.html">
            
                    
                    修改DOM结构
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../Jquery/事件.html">
            
                <a href="../Jquery/事件.html">
            
                    
                    事件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../Jquery/动画.html">
            
                <a href="../Jquery/动画.html">
            
                    
                    动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../Jquery/AJAX.html">
            
                <a href="../Jquery/AJAX.html">
            
                    
                    AJAX
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../Jquery/扩展.html">
            
                <a href="../Jquery/扩展.html">
            
                    
                    扩展
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../nodejs/nodejs.html">
            
                <a href="../nodejs/nodejs.html">
            
                    
                    Nodejs
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../nodejs/模块.html">
            
                <a href="../nodejs/模块.html">
            
                    
                    模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../nodejs/path.html">
            
                <a href="../nodejs/path.html">
            
                    
                    path
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../nodejs/文件操作.html">
            
                <a href="../nodejs/文件操作.html">
            
                    
                    文件操作 fs
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../nodejs/流Stream.html">
            
                <a href="../nodejs/流Stream.html">
            
                    
                    流Stream
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../nodejs/zlib压缩解压缩.html">
            
                <a href="../nodejs/zlib压缩解压缩.html">
            
                    
                    zlib压缩解压缩
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../nodejs/net网络.html">
            
                <a href="../nodejs/net网络.html">
            
                    
                    net网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../nodejs/http.html">
            
                <a href="../nodejs/http.html">
            
                    
                    http
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../nodejs/express框架.html">
            
                <a href="../nodejs/express框架.html">
            
                    
                    express框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="../nodejs/process进程.html">
            
                <a href="../nodejs/process进程.html">
            
                    
                    process 进程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.10" data-path="../nodejs/child_process.html">
            
                <a href="../nodejs/child_process.html">
            
                    
                    child_process
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.11" data-path="../nodejs/os.html">
            
                <a href="../nodejs/os.html">
            
                    
                    os-操作系统
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../react/react.html">
            
                <a href="../react/react.html">
            
                    
                    React
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >编程风格</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x7F16;&#x7A0B;&#x98CE;&#x683C;">&#x7F16;&#x7A0B;&#x98CE;&#x683C;</h1>
<h3 id="&#x5757;&#x7EA7;&#x4F5C;&#x7528;&#x57DF;">&#x5757;&#x7EA7;&#x4F5C;&#x7528;&#x57DF;</h3>
<h4 id="let&#x4EE3;&#x66FF;var">let&#x4EE3;&#x66FF;var</h4>
<p>ES6 &#x63D0;&#x51FA;&#x4E86;&#x4E24;&#x4E2A;&#x65B0;&#x7684;&#x58F0;&#x660E;&#x53D8;&#x91CF;&#x7684;&#x547D;&#x4EE4;&#xFF1A;<code>let</code>&#x548C;<code>const</code>&#x3002;&#x5176;&#x4E2D;&#xFF0C;<code>let</code>&#x5B8C;&#x5168;&#x53EF;&#x4EE5;&#x53D6;&#x4EE3;<code>var</code>&#xFF0C;&#x56E0;&#x4E3A;&#x4E24;&#x8005;&#x8BED;&#x4E49;&#x76F8;&#x540C;&#xFF0C;&#x800C;&#x4E14;<code>let</code>&#x6CA1;&#x6709;&#x526F;&#x4F5C;&#x7528;&#x3002;</p>
<h4 id="&#x5168;&#x5C40;&#x5E38;&#x91CF;&#x548C;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;">&#x5168;&#x5C40;&#x5E38;&#x91CF;&#x548C;&#x7EBF;&#x7A0B;&#x5B89;&#x5168;</h4>
<p>&#x5728;<code>let</code>&#x548C;<code>const</code>&#x4E4B;&#x95F4;&#xFF0C;&#x5EFA;&#x8BAE;&#x4F18;&#x5148;&#x4F7F;&#x7528;<code>const</code>&#xFF0C;&#x5C24;&#x5176;&#x662F;&#x5728;&#x5168;&#x5C40;&#x73AF;&#x5883;&#xFF0C;&#x4E0D;&#x5E94;&#x8BE5;&#x8BBE;&#x7F6E;&#x53D8;&#x91CF;&#xFF0C;&#x53EA;&#x5E94;&#x8BBE;&#x7F6E;&#x5E38;&#x91CF;&#x3002;</p>
<hr>
<h3 id="&#x5B57;&#x7B26;&#x4E32;">&#x5B57;&#x7B26;&#x4E32;</h3>
<p>&#x9759;&#x6001;&#x5B57;&#x7B26;&#x4E32;&#x4E00;&#x5F8B;&#x4F7F;&#x7528;&#x5355;&#x5F15;&#x53F7;&#x6216;&#x53CD;&#x5F15;&#x53F7;&#xFF0C;&#x4E0D;&#x4F7F;&#x7528;&#x53CC;&#x5F15;&#x53F7;&#x3002;&#x52A8;&#x6001;&#x5B57;&#x7B26;&#x4E32;&#x4F7F;&#x7528;&#x53CD;&#x5F15;&#x53F7;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// bad</span>
<span class="hljs-keyword">const</span> a = <span class="hljs-string">&quot;foobar&quot;</span>;
<span class="hljs-keyword">const</span> b = <span class="hljs-string">&apos;foo&apos;</span> + a + <span class="hljs-string">&apos;bar&apos;</span>;

<span class="hljs-comment">// acceptable</span>
<span class="hljs-keyword">const</span> c = <span class="hljs-string">`foobar`</span>;

<span class="hljs-comment">// good</span>
<span class="hljs-keyword">const</span> a = <span class="hljs-string">&apos;foobar&apos;</span>;
<span class="hljs-keyword">const</span> b = <span class="hljs-string">`foo<span class="hljs-subst">${a}</span>bar`</span>;
</code></pre>
<hr>
<h3 id="&#x89E3;&#x6784;&#x8D4B;&#x503C;">&#x89E3;&#x6784;&#x8D4B;&#x503C;</h3>
<p>&#x4F7F;&#x7528;&#x6570;&#x7EC4;&#x6210;&#x5458;&#x5BF9;&#x53D8;&#x91CF;&#x8D4B;&#x503C;&#x65F6;&#xFF0C;&#x4F18;&#x5148;&#x4F7F;&#x7528;&#x89E3;&#x6784;&#x8D4B;&#x503C;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> arr = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>];

<span class="hljs-comment">// bad</span>
<span class="hljs-keyword">const</span> first = arr[<span class="hljs-number">0</span>];
<span class="hljs-keyword">const</span> second = arr[<span class="hljs-number">1</span>];

<span class="hljs-comment">// good</span>
<span class="hljs-keyword">const</span> [first, second] = arr;
</code></pre>
<p>&#x51FD;&#x6570;&#x7684;&#x53C2;&#x6570;&#x5982;&#x679C;&#x662F;&#x5BF9;&#x8C61;&#x7684;&#x6210;&#x5458;&#xFF0C;&#x4F18;&#x5148;&#x4F7F;&#x7528;&#x89E3;&#x6784;&#x8D4B;&#x503C;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// bad</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getFullName</span>(<span class="hljs-params">user</span>) </span>{
  <span class="hljs-keyword">const</span> firstName = user.firstName;
  <span class="hljs-keyword">const</span> lastName = user.lastName;
}

<span class="hljs-comment">// good</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getFullName</span>(<span class="hljs-params">obj</span>) </span>{
  <span class="hljs-keyword">const</span> { firstName, lastName } = obj;
}

<span class="hljs-comment">// best</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getFullName</span>(<span class="hljs-params">{ firstName, lastName }</span>) </span>{
}
</code></pre>
<p>&#x5982;&#x679C;&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x591A;&#x4E2A;&#x503C;&#xFF0C;&#x4F18;&#x5148;&#x4F7F;&#x7528;&#x5BF9;&#x8C61;&#x7684;&#x89E3;&#x6784;&#x8D4B;&#x503C;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x6570;&#x7EC4;&#x7684;&#x89E3;&#x6784;&#x8D4B;&#x503C;&#x3002;&#x8FD9;&#x6837;&#x4FBF;&#x4E8E;&#x4EE5;&#x540E;&#x6DFB;&#x52A0;&#x8FD4;&#x56DE;&#x503C;&#xFF0C;&#x4EE5;&#x53CA;&#x66F4;&#x6539;&#x8FD4;&#x56DE;&#x503C;&#x7684;&#x987A;&#x5E8F;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// bad</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">processInput</span>(<span class="hljs-params">input</span>) </span>{
  <span class="hljs-keyword">return</span> [left, right, top, bottom];
}

<span class="hljs-comment">// good</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">processInput</span>(<span class="hljs-params">input</span>) </span>{
  <span class="hljs-keyword">return</span> { left, right, top, bottom };
}

<span class="hljs-keyword">const</span> { left, right } = processInput(input);
</code></pre>
<h3 id="&#x5BF9;&#x8C61;">&#x5BF9;&#x8C61;</h3>
<p>&#x5355;&#x884C;&#x5B9A;&#x4E49;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x6210;&#x5458;&#x4E0D;&#x4EE5;&#x9017;&#x53F7;&#x7ED3;&#x5C3E;&#x3002;&#x591A;&#x884C;&#x5B9A;&#x4E49;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x6210;&#x5458;&#x4EE5;&#x9017;&#x53F7;&#x7ED3;&#x5C3E;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// bad</span>
<span class="hljs-keyword">const</span> a = { k1: v1, k2: v2, };
<span class="hljs-keyword">const</span> b = {
  k1: v1,
  k2: v2
};

<span class="hljs-comment">// good</span>
<span class="hljs-keyword">const</span> a = { k1: v1, k2: v2 };
<span class="hljs-keyword">const</span> b = {
  k1: v1,
  k2: v2,
};
</code></pre>
<p>&#x5BF9;&#x8C61;&#x5C3D;&#x91CF;&#x9759;&#x6001;&#x5316;&#xFF0C;&#x4E00;&#x65E6;&#x5B9A;&#x4E49;&#xFF0C;&#x5C31;&#x4E0D;&#x5F97;&#x968F;&#x610F;&#x6DFB;&#x52A0;&#x65B0;&#x7684;&#x5C5E;&#x6027;&#x3002;&#x5982;&#x679C;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;&#x4E0D;&#x53EF;&#x907F;&#x514D;&#xFF0C;&#x8981;&#x4F7F;&#x7528;<code>Object.assign</code>&#x65B9;&#x6CD5;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// bad</span>
<span class="hljs-keyword">const</span> a = {};
a.x = <span class="hljs-number">3</span>;

<span class="hljs-comment">// if reshape unavoidable</span>
<span class="hljs-keyword">const</span> a = {};
<span class="hljs-built_in">Object</span>.assign(a, { x: <span class="hljs-number">3</span> });

<span class="hljs-comment">// good</span>
<span class="hljs-keyword">const</span> a = { x: <span class="hljs-literal">null</span> };
a.x = <span class="hljs-number">3</span>;
</code></pre>
<p>&#x5982;&#x679C;&#x5BF9;&#x8C61;&#x7684;&#x5C5E;&#x6027;&#x540D;&#x662F;&#x52A8;&#x6001;&#x7684;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;&#x521B;&#x9020;&#x5BF9;&#x8C61;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4F7F;&#x7528;&#x5C5E;&#x6027;&#x8868;&#x8FBE;&#x5F0F;&#x5B9A;&#x4E49;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// bad</span>
<span class="hljs-keyword">const</span> obj = {
  id: <span class="hljs-number">5</span>,
  name: <span class="hljs-string">&apos;San Francisco&apos;</span>,
};
obj[getKey(<span class="hljs-string">&apos;enabled&apos;</span>)] = <span class="hljs-literal">true</span>;

<span class="hljs-comment">// good</span>
<span class="hljs-keyword">const</span> obj = {
  id: <span class="hljs-number">5</span>,
  name: <span class="hljs-string">&apos;San Francisco&apos;</span>,
  [getKey(<span class="hljs-string">&apos;enabled&apos;</span>)]: <span class="hljs-literal">true</span>,
};
</code></pre>
<p>&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x4E2D;&#xFF0C;&#x5BF9;&#x8C61;<code>obj</code>&#x7684;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x5C5E;&#x6027;&#x540D;&#xFF0C;&#x9700;&#x8981;&#x8BA1;&#x7B97;&#x5F97;&#x5230;&#x3002;&#x8FD9;&#x65F6;&#x6700;&#x597D;&#x91C7;&#x7528;&#x5C5E;&#x6027;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x5728;&#x65B0;&#x5EFA;<code>obj</code>&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5C06;&#x8BE5;&#x5C5E;&#x6027;&#x4E0E;&#x5176;&#x4ED6;&#x5C5E;&#x6027;&#x5B9A;&#x4E49;&#x5728;&#x4E00;&#x8D77;&#x3002;&#x8FD9;&#x6837;&#x4E00;&#x6765;&#xFF0C;&#x6240;&#x6709;&#x5C5E;&#x6027;&#x5C31;&#x5728;&#x4E00;&#x4E2A;&#x5730;&#x65B9;&#x5B9A;&#x4E49;&#x4E86;&#x3002;</p>
<p>&#x53E6;&#x5916;&#xFF0C;&#x5BF9;&#x8C61;&#x7684;&#x5C5E;&#x6027;&#x548C;&#x65B9;&#x6CD5;&#xFF0C;&#x5C3D;&#x91CF;&#x91C7;&#x7528;&#x7B80;&#x6D01;&#x8868;&#x8FBE;&#x6CD5;&#xFF0C;&#x8FD9;&#x6837;&#x6613;&#x4E8E;&#x63CF;&#x8FF0;&#x548C;&#x4E66;&#x5199;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> ref = <span class="hljs-string">&apos;some value&apos;</span>;

<span class="hljs-comment">// bad</span>
<span class="hljs-keyword">const</span> atom = {
  ref: ref,

  value: <span class="hljs-number">1</span>,

  addValue: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">value</span>) </span>{
    <span class="hljs-keyword">return</span> atom.value + value;
  },
};

<span class="hljs-comment">// good</span>
<span class="hljs-keyword">const</span> atom = {
  ref,

  value: <span class="hljs-number">1</span>,

  addValue(value) {
    <span class="hljs-keyword">return</span> atom.value + value;
  },
};
</code></pre>
<h3 id="&#x6570;&#x7EC4;">&#x6570;&#x7EC4;</h3>
<p>&#x4F7F;&#x7528;&#x6269;&#x5C55;&#x8FD0;&#x7B97;&#x7B26;&#xFF08;...&#xFF09;&#x62F7;&#x8D1D;&#x6570;&#x7EC4;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// bad</span>
<span class="hljs-keyword">const</span> len = items.length;
<span class="hljs-keyword">const</span> itemsCopy = [];
<span class="hljs-keyword">let</span> i;

<span class="hljs-keyword">for</span> (i = <span class="hljs-number">0</span>; i &lt; len; i++) {
  itemsCopy[i] = items[i];
}

<span class="hljs-comment">// good</span>
<span class="hljs-keyword">const</span> itemsCopy = [...items];
</code></pre>
<p>&#x4F7F;&#x7528; Array.from &#x65B9;&#x6CD5;&#xFF0C;&#x5C06;&#x7C7B;&#x4F3C;&#x6570;&#x7EC4;&#x7684;&#x5BF9;&#x8C61;&#x8F6C;&#x4E3A;&#x6570;&#x7EC4;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> foo = <span class="hljs-built_in">document</span>.querySelectorAll(<span class="hljs-string">&apos;.foo&apos;</span>);
<span class="hljs-keyword">const</span> nodes = <span class="hljs-built_in">Array</span>.from(foo);
</code></pre>
<h3 id="&#x51FD;&#x6570;">&#x51FD;&#x6570;</h3>
<p>&#x90A3;&#x4E9B;&#x4F7F;&#x7528;&#x533F;&#x540D;&#x51FD;&#x6570;&#x5F53;&#x4F5C;&#x53C2;&#x6570;&#x7684;&#x573A;&#x5408;&#xFF0C;&#x5C3D;&#x91CF;&#x7528;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x4EE3;&#x66FF;&#x3002;&#x56E0;&#x4E3A;&#x8FD9;&#x6837;&#x66F4;&#x7B80;&#x6D01;&#xFF0C;&#x800C;&#x4E14;&#x7ED1;&#x5B9A;&#x4E86; this&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// bad</span>
[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>].map(<span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">x</span>) </span>{
  <span class="hljs-keyword">return</span> x * x;
});

<span class="hljs-comment">// good</span>
[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>].map((x) =&gt; {
  <span class="hljs-keyword">return</span> x * x;
});

<span class="hljs-comment">// best</span>
[<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>].map(x =&gt; x * x);
</code></pre>
<p>&#x6240;&#x6709;&#x914D;&#x7F6E;&#x9879;&#x90FD;&#x5E94;&#x8BE5;&#x96C6;&#x4E2D;&#x5728;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#xFF0C;&#x653E;&#x5728;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x5E03;&#x5C14;&#x503C;&#x4E0D;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F5C;&#x4E3A;&#x53C2;&#x6570;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// bad</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">divide</span>(<span class="hljs-params">a, b, option = false </span>) </span>{
}

<span class="hljs-comment">// good</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">divide</span>(<span class="hljs-params">a, b, { option = false } = {}</span>) </span>{
}
</code></pre>
<p>&#x4E0D;&#x8981;&#x5728;&#x51FD;&#x6570;&#x4F53;&#x5185;&#x4F7F;&#x7528; arguments &#x53D8;&#x91CF;&#xFF0C;&#x4F7F;&#x7528; rest &#x8FD0;&#x7B97;&#x7B26;&#xFF08;...&#xFF09;&#x4EE3;&#x66FF;&#x3002;&#x56E0;&#x4E3A; rest &#x8FD0;&#x7B97;&#x7B26;&#x663E;&#x5F0F;&#x8868;&#x660E;&#x4F60;&#x60F3;&#x8981;&#x83B7;&#x53D6;&#x53C2;&#x6570;&#xFF0C;&#x800C;&#x4E14; arguments &#x662F;&#x4E00;&#x4E2A;&#x7C7B;&#x4F3C;&#x6570;&#x7EC4;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x800C; rest &#x8FD0;&#x7B97;&#x7B26;&#x53EF;&#x4EE5;&#x63D0;&#x4F9B;&#x4E00;&#x4E2A;&#x771F;&#x6B63;&#x7684;&#x6570;&#x7EC4;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// bad</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">concatenateAll</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> args = <span class="hljs-built_in">Array</span>.prototype.slice.call(<span class="hljs-built_in">arguments</span>);
  <span class="hljs-keyword">return</span> args.join(<span class="hljs-string">&apos;&apos;</span>);
}

<span class="hljs-comment">// good</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">concatenateAll</span>(<span class="hljs-params">...args</span>) </span>{
  <span class="hljs-keyword">return</span> args.join(<span class="hljs-string">&apos;&apos;</span>);
}
</code></pre>
<p>&#x4F7F;&#x7528;&#x9ED8;&#x8BA4;&#x503C;&#x8BED;&#x6CD5;&#x8BBE;&#x7F6E;&#x51FD;&#x6570;&#x53C2;&#x6570;&#x7684;&#x9ED8;&#x8BA4;&#x503C;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// bad</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">handleThings</span>(<span class="hljs-params">opts</span>) </span>{
  opts = opts || {};
}

<span class="hljs-comment">// good</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">handleThings</span>(<span class="hljs-params">opts = {}</span>) </span>{
  <span class="hljs-comment">// ...</span>
}
</code></pre>
<h3 id="map&#x7ED3;&#x6784;">Map&#x7ED3;&#x6784;</h3>
<p>&#x6CE8;&#x610F;&#x533A;&#x5206; Object &#x548C; Map&#xFF0C;&#x53EA;&#x6709;&#x6A21;&#x62DF;&#x73B0;&#x5B9E;&#x4E16;&#x754C;&#x7684;&#x5B9E;&#x4F53;&#x5BF9;&#x8C61;&#x65F6;&#xFF0C;&#x624D;&#x4F7F;&#x7528; Object&#x3002;&#x5982;&#x679C;&#x53EA;&#x662F;&#x9700;&#x8981;<code>key: value</code>&#x7684;&#x6570;&#x636E;&#x7ED3;&#x6784;&#xFF0C;&#x4F7F;&#x7528; Map &#x7ED3;&#x6784;&#x3002;&#x56E0;&#x4E3A; Map &#x6709;&#x5185;&#x5EFA;&#x7684;&#x904D;&#x5386;&#x673A;&#x5236;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> map = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Map</span>(arr);

<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> key <span class="hljs-keyword">of</span> map.keys()) {
  <span class="hljs-built_in">console</span>.log(key);
}

<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> value <span class="hljs-keyword">of</span> map.values()) {
  <span class="hljs-built_in">console</span>.log(value);
}

<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> item <span class="hljs-keyword">of</span> map.entries()) {
  <span class="hljs-built_in">console</span>.log(item[<span class="hljs-number">0</span>], item[<span class="hljs-number">1</span>]);
}
</code></pre>
<hr>
<h3 id="class">class</h3>
<p>&#x603B;&#x662F;&#x7528; Class&#xFF0C;&#x53D6;&#x4EE3;&#x9700;&#x8981; prototype &#x7684;&#x64CD;&#x4F5C;&#x3002;&#x56E0;&#x4E3A; Class &#x7684;&#x5199;&#x6CD5;&#x66F4;&#x7B80;&#x6D01;&#xFF0C;&#x66F4;&#x6613;&#x4E8E;&#x7406;&#x89E3;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// bad</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Queue</span>(<span class="hljs-params">contents = []</span>) </span>{
  <span class="hljs-keyword">this</span>._queue = [...contents];
}
Queue.prototype.pop = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">const</span> value = <span class="hljs-keyword">this</span>._queue[<span class="hljs-number">0</span>];
  <span class="hljs-keyword">this</span>._queue.splice(<span class="hljs-number">0</span>, <span class="hljs-number">1</span>);
  <span class="hljs-keyword">return</span> value;
}

<span class="hljs-comment">// good</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Queue</span> </span>{
  <span class="hljs-keyword">constructor</span>(contents = []) {
    <span class="hljs-keyword">this</span>._queue = [...contents];
  }
  pop() {
    <span class="hljs-keyword">const</span> value = <span class="hljs-keyword">this</span>._queue[<span class="hljs-number">0</span>];
    <span class="hljs-keyword">this</span>._queue.splice(<span class="hljs-number">0</span>, <span class="hljs-number">1</span>);
    <span class="hljs-keyword">return</span> value;
  }
}
</code></pre>
<p>&#x4F7F;&#x7528;<code>extends</code>&#x5B9E;&#x73B0;&#x7EE7;&#x627F;&#xFF0C;&#x56E0;&#x4E3A;&#x8FD9;&#x6837;&#x66F4;&#x7B80;&#x5355;&#xFF0C;&#x4E0D;&#x4F1A;&#x6709;&#x7834;&#x574F;<code>instanceof</code>&#x8FD0;&#x7B97;&#x7684;&#x5371;&#x9669;&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// bad</span>
<span class="hljs-keyword">const</span> inherits = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;inherits&apos;</span>);
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">PeekableQueue</span>(<span class="hljs-params">contents</span>) </span>{
  Queue.apply(<span class="hljs-keyword">this</span>, contents);
}
inherits(PeekableQueue, Queue);
PeekableQueue.prototype.peek = <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>._queue[<span class="hljs-number">0</span>];
}

<span class="hljs-comment">// good</span>
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">PeekableQueue</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Queue</span> </span>{
  peek() {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>._queue[<span class="hljs-number">0</span>];
  }
}
</code></pre>
<h3 id="&#x6A21;&#x5757;">&#x6A21;&#x5757;</h3>
<p>&#x9996;&#x5148;&#xFF0C;Module &#x8BED;&#x6CD5;&#x662F; JavaScript &#x6A21;&#x5757;&#x7684;&#x6807;&#x51C6;&#x5199;&#x6CD5;&#xFF0C;&#x575A;&#x6301;&#x4F7F;&#x7528;&#x8FD9;&#x79CD;&#x5199;&#x6CD5;&#x3002;&#x4F7F;&#x7528;<code>import</code>&#x53D6;&#x4EE3;<code>require</code>&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// bad</span>
<span class="hljs-keyword">const</span> moduleA = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;moduleA&apos;</span>);
<span class="hljs-keyword">const</span> func1 = moduleA.func1;
<span class="hljs-keyword">const</span> func2 = moduleA.func2;

<span class="hljs-comment">// good</span>
<span class="hljs-keyword">import</span> { func1, func2 } <span class="hljs-keyword">from</span> <span class="hljs-string">&apos;moduleA&apos;</span>;
</code></pre>
<p>&#x4F7F;&#x7528;<code>export</code>&#x53D6;&#x4EE3;<code>module.exports</code>&#x3002;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// commonJS&#x7684;&#x5199;&#x6CD5;</span>
<span class="hljs-keyword">var</span> React = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;react&apos;</span>);

<span class="hljs-keyword">var</span> Breadcrumbs = React.createClass({
  render() {
    <span class="hljs-keyword">return</span> &lt;nav /&gt;;
  }
});

module.exports = Breadcrumbs;

// ES6&#x7684;&#x5199;&#x6CD5;
import React from &apos;react&apos;;

class Breadcrumbs extends React.Component {
  render() {
    return &lt;nav /&gt;;
  }
};

export default Breadcrumbs;
</code></pre>
<p>&#x5982;&#x679C;&#x6A21;&#x5757;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x8F93;&#x51FA;&#x503C;&#xFF0C;&#x5C31;&#x4F7F;&#x7528;<code>export default</code>&#xFF0C;&#x5982;&#x679C;&#x6A21;&#x5757;&#x6709;&#x591A;&#x4E2A;&#x8F93;&#x51FA;&#x503C;&#xFF0C;&#x5C31;&#x4E0D;&#x4F7F;&#x7528;<code>export default</code>&#xFF0C;<code>export default</code>&#x4E0E;&#x666E;&#x901A;&#x7684;<code>export</code>&#x4E0D;&#x8981;&#x540C;&#x65F6;&#x4F7F;&#x7528;&#x3002;</p>
<h3 id="elint&#x7684;&#x4F7F;&#x7528;">ELint&#x7684;&#x4F7F;&#x7528;</h3>
<p>ESLint &#x662F;&#x4E00;&#x4E2A;&#x8BED;&#x6CD5;&#x89C4;&#x5219;&#x548C;&#x4EE3;&#x7801;&#x98CE;&#x683C;&#x7684;&#x68C0;&#x67E5;&#x5DE5;&#x5177;&#xFF0C;&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x4FDD;&#x8BC1;&#x5199;&#x51FA;&#x8BED;&#x6CD5;&#x6B63;&#x786E;&#x3001;&#x98CE;&#x683C;&#x7EDF;&#x4E00;&#x7684;&#x4EE3;&#x7801;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="异常处理.html" class="navigation navigation-prev " aria-label="Previous page: 异常处理">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../js扩展/js扩展.html" class="navigation navigation-next " aria-label="Next page: js 扩展">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"编程风格","level":"1.2.12","depth":2,"next":{"title":"js 扩展","level":"1.3","depth":1,"path":"js扩展/js扩展.md","ref":"js扩展/js扩展.md","articles":[{"title":"字符串","level":"1.3.1","depth":2,"path":"js扩展/字符串.md","ref":"js扩展/字符串.md","articles":[]}]},"previous":{"title":"异常处理","level":"1.2.11","depth":2,"path":"基础/异常处理.md","ref":"基础/异常处理.md","articles":[]},"dir":"ltr"},"config":{"plugins":["lunr","pageview-count","chapter-fold","back-to-top-button","code","hide-element","-sharing","sharing-plus","custom-favicon"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"chapter-fold":{},"search":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"lunr":{"ignoreSpecialCharacters":false,"maxIndexSize":1000000},"code":{"copyButtons":true},"hide-element":{"elements":[".gitbook-link"]},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"favicon":"js.ico","back-to-top-button":{},"pageview-count":{},"custom-favicon":{},"sharing":{"qq":true,"all":["douban","facebook","google","instapaper","linkedin","twitter","weibo","messenger","qq","qzone","viber","whatsapp"],"douban":true,"facebook":true,"weibo":true,"twitter":true,"pocket":true,"google":true,"qzone":true},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Veng","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"JavaScript学习","language":"zh-hans","gitbook":"*","description":"javaScript的学习笔记"},"file":{"path":"基础/编程风格.md","mtime":"2020-12-10T02:10:04.990Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-12-10T03:00:51.663Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

